<template>
  <div class="home">
    <h2>我是首页</h2>
    <button @click="addNumAsync">异步赋值num</button>
    <button @click="addNum">+</button>
    {{ $store.state.num }}
  </div>
</template>

<script>

export default {
  name: 'home',
  data: () => {
    return {
      msg: '你好世界'
    }
  },
  methods: {
    addNumAsync () {
      console.log(this.$store)
      this.$store.dispatch('addNumAsync', 10)
    },
    addNum () {
      this.$store.commit('addNum', 5)
    }
  },
  mounted () {
    console.log(this)
  }
}
</script>
<style lang="scss" scoped>
  /deep/ h2{
    color: red;
  }
</style>
